package com.news.servlet;

import com.news.db.OpDB;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 根据id删除新闻人物
 */
@WebServlet("/delP")
public class DelPersonServlt extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.获取数据
        String id = req.getParameter("id");
        //2.调用dao方法
        OpDB opdb = new OpDB();
        opdb.delPerson(id);
        //3.转发
        req.getRequestDispatcher("/pageperson?rows=2&currentPage=1").forward(req, resp);
    }
}
